<?php
$width=Yii::app()->params['dialog']['findTruckForVerification']['width'];
$height=Yii::app()->params['dialog']['findTruckForVerification']['height'];
$cs=Yii::app()->clientScript;
$cs->registerScriptFile('./js/modal.js');
$cs->registerScript('truck_verification_dialog',<<<END
function Block(){
var title; var kind=$("#Annual_verification_kind").val();
if(kind==0) title="请选择车辆"; else title="请选择尾板";
 \$.modal('?r=dialog/findTruckForVerification&kind='+kind,{width:$width,height:$height,title:title});return false;}
$("#findTruck").click(Block);
$("#Annual_verification_kind").change(function(){\$("#Annual_verification_plate_no").val('');$("#Annual_verification_fk_truck_id").val('');$("#Annual_verification_property_owner").val('');});
$("#calculate").click(function(){
	var vaild=true;
	var validator=$("form").validate();//alert(validator.element($('#Accident_record_plate_no')));
	var cost=0;
	validator.resetForm();
	$("form input:gt(4):lt(7)").each(function(i,item){
		vaild=validator.element($(item))?vaild:false;
	});
	if(!vaild) {alert('请将信息填写完整信息!');return;}
	$("form input:gt(4):lt(7)").each(function(i,item){
		cost+=Number($(item).attr('value'));
	});
	$("#Annual_verification_total_cost").val(Math.round(cost*100)/100);
});
$('form').submit(function(){\$("#calculate").click();});
END
)
?>
<div class="yiiForm">
<?php
	echo EHtml::form();	
	EHtml::setOptions(array('errorElement'=> 'span'));
	EHtml::setScenario($update ? 'update' : 'create');				  		
?>
<div>注：<span class="required">*</span>为必填项</div>
<div id="leftaa">
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'kind'); ?>
<?php echo EHtml::activeDropDownList($model,'kind',$model->getKindNames()); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'plate_no'); ?>
<?php echo EHtml::activeTextField($model,'plate_no',array('size'=>7,'readOnly'=>'true','class'=>'readonly')); ?>
<?php echo CHtml::activeHiddenField($model,'fk_truck_id');?>&nbsp;&nbsp;<a id="findTruck" href="#">查找车辆/尾板</a>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'property_owner'); ?>
<?php echo EHtml::activeTextField($model,'property_owner',array('readOnly'=>'true','class'=>'readonly')); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'verify_date'); ?>
<?php echo EHtml::activeTextField($model,'verify_date',array('id'=>'verify_date','size'=>10)); ?>
<?php $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'verify_date','ifFormat'=>'%Y-%m-%d',));?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'next_verify_date'); ?>
<?php echo EHtml::activeTextField($model,'next_verify_date',array('id'=>'next_verify_date','size'=>10)); ?>
<?php $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'next_verify_date','ifFormat'=>'%Y-%m-%d',));?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'boxed_cost'); ?>
<?php echo EHtml::activeTextField($model,'boxed_cost',array('size'=>8,'format'=>'%.2f')); ?>
</div>

<div class="simple">
<?php echo CHtml::activeLabelEx($model,'vvulpt_cost'); ?>
<?php echo EHtml::activeTextField($model,'vvulpt_cost',array('size'=>8,'format'=>'%.2f')); ?>
</div>
</div>
  <div id="rightaa">
  <div class="simple">
<?php echo CHtml::activeLabelEx($model,'detection_cost'); ?>
<?php echo EHtml::activeTextField($model,'detection_cost',array('size'=>8,'format'=>'%.2f')); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'plate_cost'); ?>
<?php echo EHtml::activeTextField($model,'plate_cost',array('size'=>8,'format'=>'%.2f')); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'film_cost'); ?>
<?php echo EHtml::activeTextField($model,'film_cost',array('size'=>8,'format'=>'%.2f')); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'paint_cost'); ?>
<?php echo EHtml::activeTextField($model,'paint_cost',array('size'=>8,'format'=>'%.2f')); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'another_cost'); ?>
<?php echo EHtml::activeTextField($model,'another_cost',array('size'=>8,'format'=>'%.2f')); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'total_cost'); ?>
<?php echo EHtml::activeTextField($model,'total_cost',array('size'=>8,'format'=>'%.2f')); ?>
</div>

<div class="simple" >
<label></label>
<input id="calculate" type="button" value="计算总费用"/>
</div>
</div>
<div class="simple4">
<?php echo CHtml::activeLabelEx($model,'remark'); ?>
<?php echo EHtml::activeTextArea($model,'remark',array('rows'=>6, 'cols'=>65)); ?>
</div>
<div class="action">
<?php echo EHtml::submitButton($update ? '更新信息' : '添加信息'); ?>
</div>

<?php echo EHtml::endForm(); ?>

</div><!-- yiiForm -->
<?php 
if($model->hasErrors()) echo "<script>alert('您填写的信息有误！请根据页面红色图标提示修改。');</script>";
?>